<?php

header('Content-type:text/json;char-set:utf-8;');
require_once("../lib/common.php");
$route=filter("func");
switch($route){
	case "index":
		index();
		break;
	case "list":
		list_();
		break;
	case "see":
		see();
		break;
	case "shu_ju_zi_dian":
		shu_ju_zi_dian();
		break;
	default:
		break;
}
function index(){
	$data=F("setting");
	$data=(array)$data;
	$data=$data['data'];
	//var_dump($data);
	$tpl=T();
	$tpl->assign("data",$data); 
	$tpl->MakeHtmlFile("index.html","index.html");
	header("location: ".SHOWAPP);
}
function list_(){
	$data=F("setting");
	$data=(array)$data;
	$data=$data['data'];
	$list=F("list");
	$list=(array)$list;
	$list=$list['data'];
	//	var_dump($list);exit;

	foreach($list as $k=>$v){
		$list[$k]["url"]=article($v["key"]);
	}
	$tpl=T();
	$tpl->assign("data",$data); 
	$tpl->assign("list",$list); 
	$tpl->MakeHtmlFile("list.html","list.html");
	header("location: ".SHOWAPP."/list.html");
}

function article($key){ 
	$tpl=T();
	$data=F("setting");
	$article=F($key);
	// var_dump($article);exit;
	$tpl->assign("data",$data); 
	$tpl->assign("article",$article["content"]); 
	$name=date("Y-m-d-H-i-s",$key).".html";
	$tpl->MakeHtmlFile($name,"article.html"); 
	return $name;
}
function see(){
	$key=filter("key");
	$name=date("Y-m-d-H-i-s",$key).".html";
	//var_dump(SHOWAPP);exit;
	header("location: ".SHOWAPP."/".$name);
 
}
//数据字典
function shu_ju_zi_dian()
{
	$url = $_SERVER['REQUEST_URI'];
	$name="shu_ju_zi_dian.php";
	$parsedUrl = parse_url($url, PHP_URL_QUERY);

	//var_dump($parsedUrl);exit;
	header("location:"."../../app/".$name."?".$parsedUrl);
}
 
?>